/*
 * Copyright (c) 2023 iQi.Co.Ltd. All rights reserved.
 */
 
using IQIGame.Onigao.Framework;
using System.Collections.Generic;
using System.Linq;
using System;
using NetProtocol.Enum;

namespace NetProtocol.POD {

	/// <summary>
	/// 每日重置数据
	/// module : structs
	/// </summary>
	public class DailyResetPOD : IPOD 
    {
        public readonly static Func<DailyResetPOD> FACTORY = () => new DailyResetPOD();
		public static Func<DailyResetPOD> DynamicFactory = FACTORY;
        
		/*-- members --*/
		/// <summary>
        /// 抽奖次数,key=Cid, value=次数
        /// </summary>
        private Dictionary<int, int> m_lotteryCnts;
		/// <summary>
        /// 兑换记录,key=cid，value=次数
        /// </summary>
        private Dictionary<int, int> m_exchangeRecords;
		
		
        public Dictionary<int, int> lotteryCnts
        {
            get
            {
                if(m_lotteryCnts == null)
                {
                    m_lotteryCnts = new();
                }
                return m_lotteryCnts;
            }
            private set => m_lotteryCnts = value;
        }
        public Dictionary<int, int> unsafe_lotteryCnts
        {
        	get => m_lotteryCnts;
        	set => m_lotteryCnts = value;
        }
        public Dictionary<int, int> exchangeRecords
        {
            get
            {
                if(m_exchangeRecords == null)
                {
                    m_exchangeRecords = new();
                }
                return m_exchangeRecords;
            }
            private set => m_exchangeRecords = value;
        }
        public Dictionary<int, int> unsafe_exchangeRecords
        {
        	get => m_exchangeRecords;
        	set => m_exchangeRecords = value;
        }
		
		/*-- constructors --*/
		public DailyResetPOD() {}
		public DailyResetPOD(Dictionary<int, int> lotteryCnts, Dictionary<int, int> exchangeRecords) {
			this.m_lotteryCnts = lotteryCnts;
			this.m_exchangeRecords = exchangeRecords;
		}
	      public void Serial(SOutputStream _out) {
            _out.Write_map_int_int(m_lotteryCnts);
            _out.Write_map_int_int(m_exchangeRecords);
        }
        
        public void UnSerial(SInputStream _in) {
            if(!_in.HasRemaining()) return;
            m_lotteryCnts = _in.Read_map_int_int();
            if(!_in.HasRemaining()) return;
            m_exchangeRecords = _in.Read_map_int_int();
        }
		
		public DailyResetPOD Clone() {
            DailyResetPOD o = DynamicFactory();
            if (m_lotteryCnts != null) {
                o.m_lotteryCnts = new (m_lotteryCnts);
            }
            if (m_exchangeRecords != null) {
                o.m_exchangeRecords = new (m_exchangeRecords);
            }
            return o;
        }
        
        public void Clear() {
            m_lotteryCnts = default;
            m_exchangeRecords = default;
        }
		
        public override string ToString() {
			string str = "";
			str += "DailyResetPOD [";
			str += "lotteryCnts=";
			str += m_lotteryCnts.ToString<int, int>();
			str += ", exchangeRecords=";
			str += m_exchangeRecords.ToString<int, int>();
			str += "]";
			return str;
		}
		
	}
}